#!env python

import requests

# Gitee API Base URL
API_URL = 'https://gitee.com/api/v5'

def get_current_user(api_token=None):
    # 替换为你的 API Token
    if api_token is None:
        import os
        api_token = os.environ['GITEE_TOKEN']
    headers = { "Authorization": f"token {api_token}" }
    response = requests.get(f"{API_URL}/user", headers=headers)
    if response.status_code == 200:
        print("获取用户信息成功:", response.json())
    else:
        print(f"请求失败，状态码：{response.status_code}, 原因: {response.text}")


if __name__ == '__main__':
    get_current_user()
